package com.two.screen.water.balance.utils

import android.app.Activity
import com.two.screen.water.balance.ui.App
import java.util.*

/**
 * 创建者     Noel
 * 创建时间   2017/5/16 13:44
 */

/*单例*/
object ActivityCollector {
    private var activities: MutableList<Activity> = ArrayList()

    fun addActivity(activity: Activity) {
        if (App.flag != -1) {
            activities.add(activity)
        }
    }

    fun removeActivity(activity: Activity) {
        activities.remove(activity)
    }

    fun finishAll() {
        activities.filterNot { it.isFinishing }
            .forEach { it.finish() }
    }
}
